package com.zr.corporate.mapper;

import com.zr.corporate.pojo.CorporateFactorySelectVo;
import com.zr.corporate.pojo.CorporateVo;
import com.zr.corporate.pojo.FactoryVo;
import com.zr.planclass.pojo.PlanClassVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by Administrator on 2019/9/21.
 */
@Mapper
public interface CorporateFactoryMapper {

    int queryCount(CorporateFactorySelectVo corporateFactorySelectVo);

    List<FactoryVo> queryData(CorporateFactorySelectVo corporateFactorySelectVo);

    @Select("select * from factory where legalPlantCode=#{legalPlantCode}")
    List<FactoryVo> queryBylegalPlantCode(String legalPlantCode);
    List<String> queryByPlantCodes(List<String> plantCodeList);

    @Select("select LegalPersonCode from corporate where LegalPersonCode=#{LegalPersonCode}")
    List<String> queryByLegalPersonCode(String LegalPersonCode);
    List<String> queryByPersonCodes(List<String> personCodeList);

    @Insert("insert into factory (legalPersonCode,legalPlantCode,enabled,legalPlantDec,createName,createTime,updateName,updateTime) values" +
            "(#{legalPersonCode},#{legalPlantCode},#{enabled},#{legalPlantDec},#{createName},#{createTime},#{updateName},#{updateTime})")
    void add(FactoryVo factoryVo);
    void addList(List<FactoryVo> factoryVoList);

    @Update("update factory set enabled=#{enabled},updateName=#{updateName},updateTime=#{updateTime} where id=#{id}")
    void updateStatus(FactoryVo factoryVo1);

    @Update("update factory set enabled=#{enabled},legalPlantDec=#{legalPlantDec}," +
            "updateName=#{updateName},updateTime=#{updateTime} where legalPlantCode=#{legalPlantCode}")
    void update(FactoryVo factoryVo1);

    @Select("select * from factory where id=#{id}")
    FactoryVo queryById(Integer id);

    @Select("select * from legalperson where userId=#{userId}")
    List<CorporateVo> queryCorporateByUserId(Integer userId);

    List<FactoryVo> queryDataExport(CorporateFactorySelectVo corporateFactorySelectVo);
}
